<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>PDOStatement 类</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="pdo.setattribute.html">« PDO::setAttribute</a></li>
      <li style="float: right;"><a href="pdostatement.bindcolumn.html">PDOStatement::bindColumn »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="book.pdo.html">PDO</a></li>
    <li>PDOStatement 类</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="class.pdostatement" class="reference">
 <h1 class="title">PDOStatement 类</h1>
 
 
 <div class="partintro"><p class="verinfo">(PHP 5 &gt;= 5.1.0, PHP 7, PHP 8, PECL pdo &gt;= 1.0.0)</p>
 

  <div class="section" id="pdostatement.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    代表一条预处理语句，并在该语句被执行后代表一个相关的结果集。
   </p>
  </div>

 
  <div class="section" id="pdostatement.synopsis">
   <h2 class="title">类摘要</h2>
 

   <div class="classsynopsis">
    <div class="ooclass">
     
    </div>

    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <strong class="classname">PDOStatement</strong>
     </span>

     <span class="oointerface"><span class="modifier">implements</span> 
       <a href="class.iteratoraggregate.html" class="interfacename">IteratorAggregate</a></span> {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 属性 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">public</span>
     <span class="type">string</span>
      <var class="varname"><a href="class.pdostatement.html#pdostatement.props.querystring">$<var class="varname">queryString</var></a></var>;</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="methodsynopsis dc-description">
    <span class="methodname"><a href="pdostatement.bindcolumn.html" class="methodname">bindColumn</a></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$column</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter reference">&$param</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter">$type</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter">$maxlen</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$driverdata</code><span class="initializer"> = ?</span></span><br>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="methodname"><a href="pdostatement.bindparam.html" class="methodname">bindParam</a></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$parameter</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter reference">&$variable</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter">$data_type</code><span class="initializer"> = PDO::PARAM_STR</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter">$length</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$driver_options</code><span class="initializer"> = ?</span></span><br>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="methodname"><a href="pdostatement.bindvalue.html" class="methodname">bindValue</a></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$parameter</code></span>, <span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$data_type</code><span class="initializer"> = PDO::PARAM_STR</span></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="methodname"><a href="pdostatement.closecursor.html" class="methodname">closeCursor</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="methodname"><a href="pdostatement.columncount.html" class="methodname">columnCount</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="methodname"><a href="pdostatement.debugdumpparams.html" class="methodname">debugDumpParams</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="methodname"><a href="pdostatement.errorcode.html" class="methodname">errorCode</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="methodname"><a href="pdostatement.errorinfo.html" class="methodname">errorInfo</a></span>(): <span class="type">array</span></div>
<div class="methodsynopsis dc-description"><span class="methodname"><a href="pdostatement.execute.html" class="methodname">execute</a></span>(<span class="methodparam"><span class="type">array</span> <code class="parameter">$input_parameters</code><span class="initializer"> = ?</span></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="methodname"><a href="pdostatement.fetch.html" class="methodname">fetch</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$fetch_style</code><span class="initializer"> = ?</span></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$cursor_orientation</code><span class="initializer"> = PDO::FETCH_ORI_NEXT</span></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$cursor_offset</code><span class="initializer"> = 0</span></span>): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="methodname"><a href="pdostatement.fetchall.html" class="methodname">fetchAll</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$fetch_style</code><span class="initializer"> = ?</span></span>, <span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$fetch_argument</code><span class="initializer"> = ?</span></span>, <span class="methodparam"><span class="type">array</span> <code class="parameter">$ctor_args</code><span class="initializer"> = array()</span></span>): <span class="type">array</span></div>
<div class="methodsynopsis dc-description"><span class="methodname"><a href="pdostatement.fetchcolumn.html" class="methodname">fetchColumn</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$column_number</code><span class="initializer"> = 0</span></span>): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="methodname"><a href="pdostatement.fetchobject.html" class="methodname">fetchObject</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$class_name</code><span class="initializer"> = &quot;stdClass&quot;</span></span>, <span class="methodparam"><span class="type">array</span> <code class="parameter">$ctor_args</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="methodname"><a href="pdostatement.getattribute.html" class="methodname">getAttribute</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$attribute</code></span>): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="methodname"><a href="pdostatement.getcolumnmeta.html" class="methodname">getColumnMeta</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$column</code></span>): <span class="type">array</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="pdostatement.getiterator.html" class="methodname">getIterator</a></span>(): <span class="type"><a href="class.iterator.html" class="type Iterator">Iterator</a></span></div>
<div class="methodsynopsis dc-description"><span class="methodname"><a href="pdostatement.nextrowset.html" class="methodname">nextRowset</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="methodname"><a href="pdostatement.rowcount.html" class="methodname">rowCount</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="methodname"><a href="pdostatement.setattribute.html" class="methodname">setAttribute</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$attribute</code></span>, <span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="methodname"><a href="pdostatement.setfetchmode.html" class="methodname">setFetchMode</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$mode</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="methodname"><a href="pdostatement.setfetchmode.html" class="methodname">setFetchMode</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$PDO::FETCH_COLUMN</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$colno</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="methodname"><a href="pdostatement.setfetchmode.html" class="methodname">setFetchMode</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$PDO::FETCH_CLASS</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$classname</code></span>, <span class="methodparam"><span class="type">array</span> <code class="parameter">$ctorargs</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="methodname"><a href="pdostatement.setfetchmode.html" class="methodname">setFetchMode</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$PDO::FETCH_INTO</code></span>, <span class="methodparam"><span class="type">object</span> <code class="parameter">$object</code></span>): <span class="type">bool</span></div>

   }</div>

  </div>
 
  <div class="section" id="pdostatement.props">
   <h2 class="title">属性</h2>
   <dl>
    
     <dt id="pdostatement.props.querystring"><var class="varname">queryString</var></dt>

     <dd>

      <p class="para">
       所用的查询字符串
      </p>
     </dd>

    
   </dl>

  </div>
 
  <div class="section">
   <h2 class="title">更新日志</h2>
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>8.0.0</td>
       <td>
        现在 <span class="classname"><strong class="classname">PDOStatement</strong></span> 的实现不是 <span class="interfacename"><a href="class.traversable.html" class="interfacename">Traversable</a></span>
        而是 <span class="interfacename"><a href="class.iteratoraggregate.html" class="interfacename">IteratorAggregate</a></span>。
       </td>
      </tr>

     </tbody>
    
   </table>

  </div>

 </div>
 
 















































































































































































 
<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="pdostatement.bindcolumn.html">PDOStatement::bindColumn</a> — 绑定一列到一个 PHP 变量</li><li><a href="pdostatement.bindparam.html">PDOStatement::bindParam</a> — 绑定一个参数到指定的变量名</li><li><a href="pdostatement.bindvalue.html">PDOStatement::bindValue</a> — 把一个值绑定到一个参数</li><li><a href="pdostatement.closecursor.html">PDOStatement::closeCursor</a> — 关闭游标，使语句能再次被执行。</li><li><a href="pdostatement.columncount.html">PDOStatement::columnCount</a> — 返回结果集中的列数</li><li><a href="pdostatement.debugdumpparams.html">PDOStatement::debugDumpParams</a> — 打印一条 SQL 预处理命令</li><li><a href="pdostatement.errorcode.html">PDOStatement::errorCode</a> — 获取跟上一次语句句柄操作相关的 SQLSTATE</li><li><a href="pdostatement.errorinfo.html">PDOStatement::errorInfo</a> — 获取跟上一次语句句柄操作相关的扩展错误信息</li><li><a href="pdostatement.execute.html">PDOStatement::execute</a> — 执行一条预处理语句</li><li><a href="pdostatement.fetch.html">PDOStatement::fetch</a> — 从结果集中获取下一行</li><li><a href="pdostatement.fetchall.html">PDOStatement::fetchAll</a> — 返回一个包含结果集中所有行的数组</li><li><a href="pdostatement.fetchcolumn.html">PDOStatement::fetchColumn</a> — 从结果集中的下一行返回单独的一列。</li><li><a href="pdostatement.fetchobject.html">PDOStatement::fetchObject</a> — 获取下一行并作为一个对象返回。</li><li><a href="pdostatement.getattribute.html">PDOStatement::getAttribute</a> — 检索一个语句属性</li><li><a href="pdostatement.getcolumnmeta.html">PDOStatement::getColumnMeta</a> — 返回结果集中一列的元数据</li><li><a href="pdostatement.getiterator.html">PDOStatement::getIterator</a> — Gets result set iterator</li><li><a href="pdostatement.nextrowset.html">PDOStatement::nextRowset</a> — 在一个多行集语句句柄中推进到下一个行集</li><li><a href="pdostatement.rowcount.html">PDOStatement::rowCount</a> — 返回受上一个 SQL 语句影响的行数</li><li><a href="pdostatement.setattribute.html">PDOStatement::setAttribute</a> — 设置一个语句属性</li><li><a href="pdostatement.setfetchmode.html">PDOStatement::setFetchMode</a> — 为语句设置默认的获取模式。</li></ul>
</div>
</div></div></body></html>